
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>

/*
 */
int main(int argc, char **argv)
{
	int fd;
	char buf[6];
    char *writebuf = "667799255";
	int len;
	

	/* 2. 打开文件 */
	fd = open("/dev/myat24c02", O_RDWR);
	if (fd == -1)
	{
		printf("can not open file /dev/hello\n");
		return -1;
	}
    // 因为是文件的读取位置 所以现在直接读是不对的？
    len = write(fd,writebuf,strlen(writebuf));
    lseek(fd, 0, SEEK_SET); //移动到开头的位置
	len = read(fd, buf, 6);		
	printf("APP read : ");
	for (len = 0; len < 6; len++)
		printf("%02x ", buf[len]);
	printf("\n");
	
	close(fd);
	
	return 0;
}


